package com.zhentao.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;

/**
 * 账户流水表，记录账户的每一笔资金变动
 * @TableName account_flow
 */
@TableName(value ="account_flow")
@Data
public class AccountFlow implements Serializable {
    /**
     * 主键ID，流水的唯一标识，用于在系统中唯一确定一笔资金流水记录
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 账户ID，关联账户表的ID，表明该笔流水属于哪个账户
     */
    private Long accountId;

    /**
     * 单据类型，关联业务单据的类型，如销售单、采购单等，用于明确资金变动的业务来源
     */
    private String billType;

    /**
     * 单据ID，关联业务单据的ID，与 bill_type 配合使用，进一步确定具体的业务单据
     */
    private Long billId;

    /**
     * 单据编号，关联业务单据的编号，方便业务人员快速查找对应的业务单据
     */
    private String billNo;

    /**
     * 流水类型，表明该笔流水是收入还是支出
     */
    private String flowType;

    /**
     * 变动金额，本次流水导致账户金额的变动数值
     */
    private BigDecimal amount;

    /**
     * 变动前金额，在该笔流水发生前账户的余额
     */
    private BigDecimal beforeAmount;

    /**
     * 变动后金额，在该笔流水发生后账户的余额
     */
    private BigDecimal afterAmount;

    /**
     * 创建时间，该笔流水记录的创建时间，用于记录流水的发生顺序和时间
     */
    private Date createTime;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        AccountFlow other = (AccountFlow) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getAccountId() == null ? other.getAccountId() == null : this.getAccountId().equals(other.getAccountId()))
            && (this.getBillType() == null ? other.getBillType() == null : this.getBillType().equals(other.getBillType()))
            && (this.getBillId() == null ? other.getBillId() == null : this.getBillId().equals(other.getBillId()))
            && (this.getBillNo() == null ? other.getBillNo() == null : this.getBillNo().equals(other.getBillNo()))
            && (this.getFlowType() == null ? other.getFlowType() == null : this.getFlowType().equals(other.getFlowType()))
            && (this.getAmount() == null ? other.getAmount() == null : this.getAmount().equals(other.getAmount()))
            && (this.getBeforeAmount() == null ? other.getBeforeAmount() == null : this.getBeforeAmount().equals(other.getBeforeAmount()))
            && (this.getAfterAmount() == null ? other.getAfterAmount() == null : this.getAfterAmount().equals(other.getAfterAmount()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getAccountId() == null) ? 0 : getAccountId().hashCode());
        result = prime * result + ((getBillType() == null) ? 0 : getBillType().hashCode());
        result = prime * result + ((getBillId() == null) ? 0 : getBillId().hashCode());
        result = prime * result + ((getBillNo() == null) ? 0 : getBillNo().hashCode());
        result = prime * result + ((getFlowType() == null) ? 0 : getFlowType().hashCode());
        result = prime * result + ((getAmount() == null) ? 0 : getAmount().hashCode());
        result = prime * result + ((getBeforeAmount() == null) ? 0 : getBeforeAmount().hashCode());
        result = prime * result + ((getAfterAmount() == null) ? 0 : getAfterAmount().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", accountId=").append(accountId);
        sb.append(", billType=").append(billType);
        sb.append(", billId=").append(billId);
        sb.append(", billNo=").append(billNo);
        sb.append(", flowType=").append(flowType);
        sb.append(", amount=").append(amount);
        sb.append(", beforeAmount=").append(beforeAmount);
        sb.append(", afterAmount=").append(afterAmount);
        sb.append(", createTime=").append(createTime);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}